<?php
include('connection.php');
// 从URL中获取sense_id参数的值
$sense_comment = $_GET['sense_comment'];
$sense_name = $_GET['sense_name'];

// 连接数据库

session_start();
$userid = $_SESSION['userid'];

    // 将sense_id与user表中的userid一起插入到route表中
    $sql = "INSERT INTO comment (userid, sense_name, sense_comment) VALUES ('$userid', '$sense_name', '$sense_comment')";
    
$result = mysqli_query($connection, $sql);
if (!$result) {
    // 关闭数据库连接
    mysqli_close($connection);
    ?>
    <script>
        alert("添加失败");
        history.back();
    </script>
    <?php
} else {
    // 关闭数据库连接
    mysqli_close($connection);
    ?>
    <script>
        alert("添加成功");
        history.back();
    </script>
    <?php } ?>